<?php
	require_once("/../Repositories/UserRepository.php");
	class UsersController extends Controller{

		private $userRepository;

		function __construct($userRepository = NULL) {
			if(!is_null($userRepository)) {
				$this->userRepository = $userRepository;
			} else {
				$this->userRepository = new UserRepository();
			}
		}

		public function Index() {
			require_once("/../ViewModels/UserRoleViewModel.php");
			$users = $this->userRepository->getUsersByProject($_SESSION['projectID']);
			$userRoles = array();
			for($i = 0; $i < sizeof($users); $i++) {
				$role = $this->userRepository->getUserRole($users[$i], $_SESSION['projectID']);
				$userRole = new UserRoleViewModel($users[$i]->name, $users[$i]->email, $role->title);
				array_push($userRoles, $userRole);
			}
			$viewData = array("Users" => $userRoles);
			$this->GetView('Index', $viewData);
		}

		public function View() {

			$viewData = array ( "User" => $this->userRepository->getUserByID($_SESSION['projectID']), );
			$this->GetView('View', $viewData);
		}

		public function Edit() {
			// write some controller code
			$this->GetView('Edit');
		}

		public function Delete() {
			// write some controller code
			$this->GetView('Delete');
		}
	
	}
?>